// -*- C++ -*-

//=============================================================================
/**
*  @file    Shared_Object_Ptr.h
*
*	@date    2009-12-17 18:08
*
*  @author wing <totti19851101@gmail.com>
*/
//=============================================================================

#ifndef _SHARED_OBJECT_PTR_H_
#define _SHARED_OBJECT_PTR_H_

#include "Pre.h"
#include "Service_Object.h"

/**
* @class Service_Object_Ptr
*
* @brief This is a smart pointer that holds onto the associated
* Service_Object * until the current scope is left, at
* which point the object's <fini> hook is called and the
* service_object_ gets deleted.
*
* This class is similar to the Standard C++ Library class
* <auto_ptr>.  
*/

class Service_Object_Ptr
{
public:
	// = Initialization and termination methods.
	/// Acquire ownership of the @a so.
	Service_Object_Ptr (Service_Object *so);

	/// Release the held Service_Object_Ptr by calling its <fini> hook.
	~Service_Object_Ptr (void);

	/// Smart pointer to access the underlying Service_Object_Ptr.
	Service_Object *operator-> ();

private:
	/// Holds the service object until we're done.
	Service_Object *service_object_;
};

#include "Post.h"
#endif//_SHARED_OBJECT_PTR_H_